<template>
	<view>
		<UserInfoCard></UserInfoCard>
		<view class="page-container">
			<view v-for="(item,index) in dataSource">
				<view class="info-sheet">
					<view class="sheet-header">
						<view class="title-container">
							<view class="sheet-dept">{{ item.theHospitalWard }}</view>
							<view class="title-bg"></view>
						</view>
						<view class="sheet-status nobook" v-if="item.patientType==1">
							未登记
						</view>
						<view class="sheet-status booked" v-if="item.patientType==2">
							已登记
						</view>
						<view class="sheet-status booked" v-if="item.patientType==3">
							已出院
						</view>
					</view>
					<view>
						<view class="sheet-row">
							<view class="label">住院患者</view>
							<view class="value">{{item.patName}}</view>
						</view>
						<view class="sheet-row">
							<view class="label">患者年龄</view>
							<view class="value">{{item.patAge}}</view>
						</view>
						<view class="sheet-row">
							<view class="label">住院院区</view>
							<view class="value">{{item.birthPlace}}</view>
						</view>
						<!-- 	<view class="sheet-row">
							<view class="label">住院病区</view>
							<view class="value">{{item.wardName}}</view>
						</view> -->
						<!-- 						<view class="sheet-row">
							<view class="label">住院位置</view>
							<view class="value">{{item.departmentAddress}}</view>
						</view> -->
						<!-- 				<view class="sheet-row">
							<view class="label">预约时间</view>
							<view class="value">{{item.reserveTime}}</view>
						</view> -->
						<!-- 						<view class="sheet-row">
							<view class="label">床位号</view>
							<view class="value">{{item.bedNum ? item.bedNum : '暂未签床'}}</view>
						</view> -->
						<view class="sheet-row">
							<view class="label">入院诊断</view>
							<view class="value">{{item.diagnosis}}</view>
						</view>
					</view>
					<ButtonAllVue v-if="item.patientType==1" btn-r="住院登记" @click="toRecordPage"></ButtonAllVue>
					<ButtonAllVue v-if="item.patientType==2" btn-r="住院缴费" @click="toPage(item)"></ButtonAllVue>
					<ButtonAllVue v-if="item.patientType==3" btn-r="住院清单" @click="toInHospitalListPage(item)">
					</ButtonAllVue>
				</view>
			</view>
		</view>
		<LoadVue :load="load"></LoadVue>
	</view>
</template>

<script>
	import InfoSheet from '../../../components/InfoSheet/InfoSheet.vue';
	import UserInfoCard from '../../../components/UserInfo/UserInfoCard.vue';
	import ButtonAllVue from '../../../components/Button/ButtonAll.vue';
	import {
		inHospitalByCardType,
		inHospitalPrepareInProof
	} from '../../../api/inHospital';
	import {
		mapGetters,
	} from 'vuex'
	export default {
		components: {
			UserInfoCard,
			InfoSheet,
			ButtonAllVue,
		},
		computed: {
			...mapGetters(["userInfo"]),
		},
		data() {
			return {
				// 原始数据（假设从后端获取）
				dataSource: [],
				showInHospitalDialog: false,
				load: false
			}
		},

		mounted() {
			this.init()
		},
		methods: {
			init() {
				// inHospitalByCardType({
				// 	// patId: this.userInfo.patId,
				// 	queryValue: '22499',
				// 	queryType: '8',
				// 	patType: '2', //患者类型 1门诊2住院
				// }).then(res => {
				// 	console.log(res)
				// 	this.dataSource = res;
				// })
				this.load = true
				inHospitalPrepareInProof({
					// cardNo: this.userInfo.patId,
					cardNo: "22499",
					"cardType": "8",
					"beginTime": "",
					"endTime": ""
				}).then(res => {
					console.log(res);
				}).finally(() => {
					this.load = false
				})
				// this.dataSource = [{
				// 		sheetTitle: '入院申请单',
				// 		patientType: 0, //0：未登记/未预约，1：已登记/已预约，2：已过号
				// 		patName: '王晴晴',
				// 		patientSex: '女',
				// 		patAge: 32,
				// 		campusName: '这是一个院区名',
				// 		deptName: '*肺病科·呼吸与危重症医学科',
				// 		wardName: '这是一个病区名',
				// 		departmentAddress: '住院楼9楼内科中心病区',
				// 		reserveTime: '2024-09-15',
				// 		diagnosis: '肺部阴影',
				// 		admissionNo: '234567876543'
				// 	},
				// 	{
				// 		sheetTitle: '住院人信息',
				// 		patientType: 1,
				// 		patientName: '王晴晴',
				// 		patientSex: '女',
				// 		patientAge: 32,
				// 		campus: '这是一个院区名',
				// 		deptName: '*肛肠科',
				// 		wardName: '这是一个病区名',
				// 		departmentAddress: '住院楼9楼内科中心病区',
				// 		admissionTime: '2024-09-15',
				// 		doctorName: '住院医生',
				// 		bedNum: '',
				// 		diagnosis: '肺部阴影',
				// 		admissionNo: '6543456765'
				// 	},
				// ]
			},
			toRecordPage() {
				// this.showInHospitalDialog = true;
				uni.navigateTo({
					url: `/pages/Home/ServeHospital/InHospitalRegisterRecord?item=`
				})
			},
			toPage(item) {
				uni.navigateTo({
					url: `/pages/Home/ServeHospital/InHospitalToPay?item=` + JSON.stringify(item)
				})
			},
			toInHospitalListPage(item) {
				uni.navigateTo({
					url: `/pages/Home/ServeHospital/InHospitalListDetail?item=` + JSON.stringify(item)
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.page-container {
		// background: linear-gradient(#e0f3ff 0%, #fff 30%);
		// min-height: 100vh;
		padding: 16rpx;
	}

	.info-sheet {
		background: #fff;
		border-radius: 16rpx;
		margin: 25rpx 0 0 0;
		box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.08);
		padding: 24rpx 32rpx 18rpx 32rpx;
	}

	.sheet-header {
		display: flex;
		align-items: center;
		justify-content: space-between;
		margin-bottom: 18rpx;
	}

	.title-container {
		position: relative;
	}

	.sheet-dept {
		font-size: 32rpx;
		color: #333;
		font-weight: bold;
	}

	.title-bg {
		position: absolute;
		width: 48rpx;
		height: 15rpx;
		background-color: rgba(65, 207, 230, 0.5);
		bottom: 0;
		left: calc(20%);
		z-index: 0;
	}

	.sheet-status {
		background: #4ad49a;
		color: #fff;
		font-size: 24rpx;
		border-radius: 8rpx;
		padding: 4rpx 18rpx;
		right: 8rpx;
	}

	.sheet-status.nobook {
		background: #eba242;
	}

	.sheet-status.booked {
		background: #bd4d4d;
	}

	.sheet-divider {
		height: 1rpx;
		border-top: 1rpx dashed #e0e0e0;
		margin: 18rpx 0 18rpx 0;
		width: 100%;
	}

	.sheet-row {
		display: flex;
		align-items: center;
		margin-bottom: 16rpx;
	}

	.label {
		color: #888;
		font-size: 28rpx;
		width: 160rpx;
	}

	.label.newchild {
		width: 170rpx;
	}

	.value {
		color: #333;
		font-size: 28rpx;
		flex: 1;
	}

	.vital {
		color: #ca3333;
	}

	.nav-btn {
		background: #e0f3ff;
		color: #1ec6e6;
		font-size: 22rpx;
		border-radius: 24rpx;
		padding: 0 18rpx;
		height: 40rpx;
		line-height: 40rpx;
		border: none;
		margin-left: 12rpx;
	}

	.sheet-btn-row {
		display: flex;
		justify-content: space-between;
		margin: 30rpx 0 15rpx;
	}

	.money-text {
		font-size: 32rpx;
		margin: 8rpx 100rpx 0 0;
	}

	.line-btn {
		width: 48%;
		height: 64rpx;
		background: #fff;
		color: #1ec6e6;
		font-size: 28rpx;
		border-radius: 44rpx;
		border: 1rpx solid #1ec6e6;
		text-align: center;
		line-height: 64rpx;
	}

	.cover-btn {
		width: 48%;
		height: 64rpx;
		background: linear-gradient(90deg, #6ed6f7 0%, #3ec6e7 100%);
		color: #fff;
		font-size: 28rpx;
		border-radius: 44rpx;
		text-align: center;
		line-height: 64rpx;
		border: none;
	}
</style>